package com.personal.dmc;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.personal.dmc.lib.CommonInfo;
import com.personal.dmc.page.BasePage;
import com.personal.dmc.page.CameraPage;
import com.personal.dmc.page.DesignMapPage;
import com.personal.dmc.page.GalleryPage;
import com.personal.dmc.page.TimeLinePage;

public class MainActivity extends Activity {
	
	private BasePage currentPage = null;
	
	private TextView timeLineButton;
	private TextView cameraButton;
	private TextView galleryButton;
	private TextView designMapButton;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	
		timeLineButton 	= (TextView) findViewById(R.id.menu_timeline);
		cameraButton 	= (TextView) findViewById(R.id.menu_camera);
		galleryButton 	= (TextView) findViewById(R.id.menu_gallery);
		designMapButton = (TextView) findViewById(R.id.menu_designmap);
		
		timeLineButton.setOnClickListener(menuButtonClicklistener);
		cameraButton.setOnClickListener(menuButtonClicklistener);
		galleryButton.setOnClickListener(menuButtonClicklistener);
		designMapButton.setOnClickListener(menuButtonClicklistener);
		
//		startActivity(new Intent(this, IntroActivity.class));
	}
	
	@Override
	protected void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
		
		/**
		 * @TODO Init the 'TimeLinePage'
		 */
		currentPage = new TimeLinePage(this);
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		
		/**
		 * @TODO Init the Recently Page
		 */
	}

	/**
	 *********** private method ***********
	 */
	/**
	 * Page를 설정한다.
	 * @param index Page Number
	 */
	public void initPage(int index)
	{
		currentPage.onDisappear();
		
		switch(index)
		{
		case CommonInfo.TIMELIVE_PAGE:
			currentPage = new TimeLinePage(this);
			break;
		case CommonInfo.CAMERA_PAGE:
			currentPage = new CameraPage(this);
			break;
		case CommonInfo.GALLERY_PAGE:
			currentPage = new GalleryPage(this);
			break;
		case CommonInfo.DESIGNMAP_PAGE:
			currentPage = new DesignMapPage(this);
			break;
		};
	}
	
	/**
	 *********** Listener ***********
	 */
	
	private View.OnClickListener menuButtonClicklistener = new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			switch(v.getId())
			{
			case R.id.menu_timeline:
				CommonInfo.currentPageIndex = CommonInfo.TIMELIVE_PAGE;
				break;
			case R.id.menu_camera:
				CommonInfo.currentPageIndex = CommonInfo.CAMERA_PAGE;
				break;
			case R.id.menu_gallery:
				CommonInfo.currentPageIndex = CommonInfo.GALLERY_PAGE;
				break;
			case R.id.menu_designmap:
				CommonInfo.currentPageIndex = CommonInfo.DESIGNMAP_PAGE;
				break;
			}
			
			initPage(CommonInfo.currentPageIndex);
		}
	};
}
